package com.yundows.safe;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class CanvasView extends View {
	int width = 0, height = 0;
	int[] rgb = null;

	public CanvasView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);

		Paint paint = new Paint();
		for (int j = 0, yp = 0; j < height; j++) {
			for (int i = 0; i < width; i++, yp++) {
				paint.setColor(rgb[yp] | 0xff000000);
				canvas.drawPoint(height - j, width - i, paint);
			}
		}
	}

	public void setDraw(int[] rgb, int width, int height) {
		this.rgb = rgb;
		this.width = width;
		this.height = height;
		this.postInvalidate();
	}

}
